﻿#pragma once
#include "../header/Client.h"
#include <string>
using namespace std;
const int PORT = 2333;
#include <QByteArray>
#include <iostream>
#include <QtWidgets/QMainWindow>
#include <qudpsocket.h>
#include <qthread.h>
#include <Windows.h>
#include <qtcpserver.h>
#include <qtcpsocket.h>
#include "../header/MainWindow.h"
class BeControl:public QObject { //受控制类

    Q_OBJECT

public:
    BeControl(QHostAddress ip);
    ~BeControl();
private:
    QTcpSocket* cli;
    std::list<std::string> opes;
private slots:
    void Receive();//接收消息并解析
    void Error(QAbstractSocket::SocketError err);       //错误处理函数
    
    void ConnectedToServer();
    void Disconnected();
};



class Control : public QThread {//控制类

    Q_OBJECT

public:
    Control(QHostAddress ip,MainWindow* m);
private:
    MainWindow* m_ptr;
    void Error(QAbstractSocket::SocketError err);
    static int  cx, cy;
    static POINT point,last_point;
    static HHOOK mouse;//鼠标钩子句柄
    static HHOOK keyboard;//键盘钩子句柄
    static bool esc_down,controling;
    static QHostAddress ip;
    void run();
    static QTcpServer* ser;
    static QTcpSocket* cli;
    static LRESULT CALLBACK CallBackProc(int nCode, WPARAM wParam, LPARAM lParam);//回调函数
    static void Quit();//退出函数
    static void Send(QString msg);//发送消息函数

private slots:
    void NewConnection();
    void Disconnected();
};



